package cn.structure.edp;

import cn.structure.ClassEntity;
import cn.structure.MethodEntity;
import cn.structure.VariableEntity;

import java.util.Objects;

public class DeputizedDelegation extends EdpEntity {
    private ClassEntity familyHead;
    private ClassEntity delegator;
    private ClassEntity delegateSibling;
    private VariableEntity target;
    private MethodEntity operation;
    private MethodEntity operation2;

    public DeputizedDelegation(ClassEntity familyHead, ClassEntity delegator, ClassEntity delegateSibling, VariableEntity target, MethodEntity operation, MethodEntity operation2) {
        super();
        this.familyHead = familyHead;
        this.delegator = delegator;
        this.delegateSibling = delegateSibling;
        this.target = target;
        this.operation = operation;
        this.operation2 = operation2;
    }

    public enum Role {
        familyHead, delegator, delegateSibling, target, operation, operation2
    }

    public ClassEntity getFamilyHead() {
        return familyHead;
    }

    public void setFamilyHead(ClassEntity familyHead) {
        this.familyHead = familyHead;
    }

    public ClassEntity getDelegator() {
        return delegator;
    }

    public void setDelegator(ClassEntity delegator) {
        this.delegator = delegator;
    }

    public ClassEntity getDelegateSibling() {
        return delegateSibling;
    }

    public void setDelegateSibling(ClassEntity delegateSibling) {
        this.delegateSibling = delegateSibling;
    }

    public VariableEntity getTarget() {
        return target;
    }

    public void setTarget(VariableEntity target) {
        this.target = target;
    }

    public MethodEntity getOperation() {
        return operation;
    }

    public void setOperation(MethodEntity operation) {
        this.operation = operation;
    }

    public MethodEntity getOperation2() {
        return operation2;
    }

    public void setOperation2(MethodEntity operation2) {
        this.operation2 = operation2;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("DeputizedDelegation{\n\t");
        sb.append(super.toString());
        sb.append("\n\t\"familyHead\":")
                .append(familyHead);
        sb.append(",\n\t\"delegator\":")
                .append(delegator);
        sb.append(",\n\t\"delegateSibling\":")
                .append(delegateSibling);
        sb.append(",\n\t\"target\":")
                .append(target);
        sb.append(",\n\t\"operation\":")
                .append(operation);
        sb.append(",\n\t\"operation2\":")
                .append(operation2);
        sb.append("\n}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        DeputizedDelegation that = (DeputizedDelegation) o;
        return Objects.equals(familyHead, that.familyHead) &&
                Objects.equals(delegator, that.delegator) &&
                Objects.equals(delegateSibling, that.delegateSibling) &&
                Objects.equals(target, that.target) &&
                Objects.equals(operation, that.operation) &&
                Objects.equals(operation2, that.operation2);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), familyHead, delegator, delegateSibling, target, operation, operation2);
    }
}
